package com.badger.zk.openfeign.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.badger.zk.openfeign.api.DemoFeignApi;

@RestController
public class DemoController {
    @Autowired(required = false)
    DemoFeignApi api;

    @GetMapping("/zk/feign/demo")
    public String demo() {
        return api.demo();
    }
    
    @Autowired
    private RestTemplate restTemplate;

    /**
     * @desc:通过Ribbon的方式进行调用
     */
    @GetMapping(value = "/getmsg")
    public String getMessage() {
        //服务名称+接口名称+参数 （/spring-cloud-user-server/getUser?name=1）
//    	badger-spring-cloud-zk-api
//        return restTemplate.getForObject("http://spring-cloud-user-server/getMessage?name=" + name, String.class);
    	return restTemplate.getForObject("http://badger-spring-cloud-zk-api/zk/demo", String.class);
    }

}
